//
//  XFBaseTableViewController.m
//  SinaBlog_OC
//
//  Created by macs on 15/11/10.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

#import "XFBaseTableViewController.h"
#import "XFOauthorViewController.h"

#import "SVProgressHUD.h"
#import "XFUserAccountModel.h"
#import "XFBaseNavController.h"

@interface XFBaseTableViewController () <XFVisitViewDelegate>

@end

@implementation XFBaseTableViewController

- (instancetype)init {
  self = [super init];
  if (self) {
    self.isLogin = [[[XFUserAccountModel alloc] init] isLogin];
  }
  return self;
}

- (void)loadView {

  _isLogin ? [super loadView] : [self loadVisitView];
}

- (void)loadVisitView {

  XFVisitView *visitView = [[XFVisitView alloc] init];
  self.visitView = visitView;
  visitView.visitViewDelegate = self;
  self.view = visitView;

  self.navigationItem.leftBarButtonItem =
      [[UIBarButtonItem alloc] initWithTitle:@"登录"
                                       style:UIBarButtonItemStylePlain
                                      target:self
                                      action:@selector(loginDidClick)];
  self.navigationItem.rightBarButtonItem =
      [[UIBarButtonItem alloc] initWithTitle:@"注册"
                                       style:UIBarButtonItemStylePlain
                                      target:self
                                      action:@selector(registDidClick)];
}

- (void)loginDidClick {
  NSLog(@"%s", __func__);
  XFOauthorViewController *oauthorView = [[XFOauthorViewController alloc] init];
  XFBaseNavController *nav =
      [[XFBaseNavController alloc] initWithRootViewController:oauthorView];
  [self presentViewController:nav animated:YES completion:nil];
}

- (void)registDidClick {
  NSLog(@"%s", __func__);
  NSArray *array = [NSArray arrayWithObjects:@"111", nil];

  NSLog(@"%@", array[2]);
}

- (void)viewWillAppear:(BOOL)animated {
  [SVProgressHUD dismiss];
  [super viewWillAppear:animated];
}

- (void)viewDidLoad {
  [super viewDidLoad];
}

@end
